FROM registry.cn-hangzhou.aliyuncs.com/zrng/dotnetaspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080

FROM registry.cn-hangzhou.aliyuncs.com/zrng/dotnetsdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

COPY ["Directory.Build.props", "."]
COPY ["Directory.Packages.props", "."]
COPY ["NuGet.Config","."]


COPY ["src/NetByDocker.Web/NetByDocker.Web.csproj", "src/NetByDocker.Web/"]
COPY ["src/NetByDocker.Domain/NetByDocker.Domain.csproj", "src/NetByDocker.Domain/"]
COPY ["src/NetByDocker.Core/NetByDocker.Core.csproj", "src/NetByDocker.Core/"]
COPY ["src/NetByDocker.ServiceDefaults/NetByDocker.ServiceDefaults.csproj", "src/NetByDocker.ServiceDefaults/"]
RUN dotnet restore "./src/NetByDocker.Web/NetByDocker.Web.csproj"
COPY . .
WORKDIR "/src/src/NetByDocker.Web"
RUN dotnet build "./NetByDocker.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./NetByDocker.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "NetByDocker.Web.dll"]